www.gusucode.com > VC++ 在线考试系统,AccessMSSQL-源码程序 > VC++ 在线考试系统,AccessMSSQL-源码程序\code\HTGL.cpp
//Download by http://www.NewXing.com // HTGL.cpp : implementation file // #include "stdafx.h" #include "OnlineTest.h" #include "HTGL.h" #include "XTSQ.h" #include "USER.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CUSER theUser; ///////////////////////////////////////////////////////////////////////////// // CHTGL dialog CHTGL::CHTGL(CWnd* pParent /*=NULL*/) : CDialog(CHTGL::IDD, pParent) { //{{AFX_DATA_INIT(CHTGL) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CHTGL::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CHTGL) DDX_Control(pDX, IDC_TAB, m_Tab); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CHTGL, CDialog) //{{AFX_MSG_MAP(CHTGL) ON_WM_PAINT() ON_WM_TIMER() ON_COMMAND(ID_MENU3_CSH, OnMenu3Csh) ON_COMMAND(ID_MENU3_QXSZ, OnMenu3Qxsz) ON_COMMAND(ID_MENU3_SCYH, OnMenu3Scyh) ON_COMMAND(ID_MENU3_SJBF, OnMenu3Sjbf) ON_COMMAND(ID_MENU3_SJHF, OnMenu3Sjhf) ON_COMMAND(ID_MENU3_TCGL, OnMenu3Tcgl) ON_COMMAND(ID_MENU3_XTSQ, OnMenu3Xtsq) ON_WM_CONTEXTMENU() ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CHTGL message handlers BOOL CHTGL::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here //状态栏 m_StatusBar.EnableAutomation(); m_StatusBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,0); int width[]={150,290,500}; m_StatusBar.SetParts(3,&width[0]); m_StatusBar.SetText("华东理工大学",0,0); CString UserName; UserName.Format("当前用户: %s",theUser.u_Name); m_StatusBar.SetText(UserName,0,1); //工具栏 TBBUTTON button[7]; TCHAR *pString; CString string; int nLength; m_ImageList.Create(32,32,ILC_COLOR32|ILC_MASK,0,0); m_ToolBar.EnableAutomation(); m_ToolBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,1); for (int i=IDI_ICON111;i<=IDI_ICON117;i++) m_ImageList.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(i))); m_ToolBar.SetImageList(&m_ImageList); for (i=0;i<7;i++) { button[i].dwData=0; button[i].fsState=TBSTATE_ENABLED; button[i].fsStyle=TBSTYLE_BUTTON; button[i].iBitmap=i; string.LoadString(i+IDS_STRING111); nLength=string.GetLength()+1; pString=string.GetBufferSetLength(nLength); button[i].iString=m_ToolBar.AddStrings(pString); string.ReleaseBuffer(); } button[0].idCommand=ID_MENU3_CSH; button[1].idCommand=ID_MENU3_SJBF; button[2].idCommand=ID_MENU3_SJHF; button[3].idCommand=ID_MENU3_XTSQ; button[4].idCommand=ID_MENU3_SCYH; button[5].idCommand=ID_MENU3_QXSZ; button[6].idCommand=ID_MENU3_TCGL; m_ToolBar.AddButtons(7,button); button[0].fsStyle=TBSTYLE_SEP; m_ToolBar.InsertButton(6,&button[0]); m_ToolBar.InsertButton(3,&button[0]); m_ToolBar.AutoSize(); m_ToolBar.SetStyle(TBSTYLE_FLAT|CCS_TOP); //选项卡 m_Tab.InsertItem(0,"欢迎使用在线考试系统"); m_Tab.InsertItem(1,"数据库管理"); m_Tab.InsertItem(2,"成员管理"); m_Tab.InsertItem(3,"权限设置"); // m_Tab.InsertItem(4,"系统问题汇总"); m_Tab.SetCurSel(0); CRect rect; m_Tab.GetClientRect(&rect); rect.DeflateRect(1,17,2,2); SjglDlg.Create(IDD_SJGL_DIALOG,&m_Tab); CyglDlg.Create(IDD_CYGL_DIALOG,&m_Tab); HysyDlg.Create(IDD_HYSY_DIALOG,&m_Tab); SjglDlg.Dlg=this; CyglDlg.Dlg=this; HysyDlg.MoveWindow(rect); HysyDlg.ShowWindow(SW_SHOW); SetTimer(3,1000,NULL); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CHTGL::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here HICON m_hIcon=::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_MAINFRAME)); SetIcon(m_hIcon,FALSE); // Do not call CDialog::OnPaint() for painting messages } void CHTGL::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default time=CTime::GetCurrentTime(); CString str="当前时间: 20"; str+=time.Format("%y-%m-%d"); str+=time.Format(" %H:%M:%S"); m_StatusBar.SetText(str,0,2); CDialog::OnTimer(nIDEvent); CDialog::OnTimer(nIDEvent); CDialog::OnTimer(nIDEvent); } void CHTGL::OnMenu3Csh() { // TODO: Add your command handler code here CRect rect; m_Tab.GetClientRect(rect); rect.DeflateRect(1,17,2,2); HysyDlg.ShowWindow(SW_HIDE); SjglDlg.ShowWindow(SW_HIDE); CyglDlg.ShowWindow(SW_HIDE); SjglDlg.MoveWindow(rect); SjglDlg.ShowWindow(SW_SHOW); m_Tab.SetCurSel(1); } void CHTGL::OnMenu3Qxsz() { // TODO: Add your command handler code here CRect rect; m_Tab.GetClientRect(rect); rect.DeflateRect(1,17,2,2); HysyDlg.ShowWindow(SW_HIDE); SjglDlg.ShowWindow(SW_HIDE); CyglDlg.ShowWindow(SW_HIDE); // CyglDlg.MoveWindow(rect); // CyglDlg.ShowWindow(SW_SHOW); m_Tab.SetCurSel(3); } void CHTGL::OnMenu3Scyh() { // TODO: Add your command handler code here CRect rect; m_Tab.GetClientRect(rect); rect.DeflateRect(1,17,2,2); HysyDlg.ShowWindow(SW_HIDE); SjglDlg.ShowWindow(SW_HIDE); CyglDlg.ShowWindow(SW_HIDE); CyglDlg.MoveWindow(rect); CyglDlg.ShowWindow(SW_SHOW); m_Tab.SetCurSel(2); } void CHTGL::OnMenu3Sjbf() { // TODO: Add your command handler code here OnMenu3Csh(); } void CHTGL::OnMenu3Sjhf() { // TODO: Add your command handler code here OnMenu3Csh(); } void CHTGL::OnMenu3Tcgl() { // TODO: Add your command handler code here if (MessageBox("您确定要退出系统吗?","系统提示",MB_YESNO)==IDYES) { KillTimer(3); OnOK(); } } void CHTGL::OnMenu3Xtsq() { // TODO: Add your command handler code here CXTSQ dlg; dlg.DoModal(); } void CHTGL::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here CRect rect; GetClientRect(&rect); CMenu menu; menu.LoadMenu(IDR_MENU3); CMenu *pContextMenu=menu.GetSubMenu(0); GetCursorPos(&point); pContextMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,point.x,point.y,this,&rect); menu.DestroyMenu(); } BOOL CHTGL::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==13) { OnMenu3Tcgl(); return true; } return CDialog::PreTranslateMessage(pMsg); } void CHTGL::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here CRect rect; m_Tab.GetClientRect(rect); rect.DeflateRect(1,17,2,2); int i=m_Tab.GetCurSel(); CyglDlg.ShowWindow(SW_HIDE); SjglDlg.ShowWindow(SW_HIDE); HysyDlg.ShowWindow(SW_HIDE); switch(i) { case 0: HysyDlg.MoveWindow(rect); HysyDlg.ShowWindow(SW_SHOW); break; case 1: SjglDlg.MoveWindow(rect); SjglDlg.ShowWindow(SW_SHOW); break; case 2: CyglDlg.MoveWindow(rect); CyglDlg.ShowWindow(SW_SHOW); break; } *pResult = 0; } void CHTGL::Xtsq() { OnMenu3Xtsq(); }